//
//  RegisterViewController.m
//  UI_xiangmu
//
//  Created by dlios on 15-4-28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RegisterViewController.h"

@interface RegisterViewController ()
//@property(nonatomic, retain)UIImageView *registerImageView;
@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self createRegisterView];
}

#pragma mark 创建视图
- (void)createRegisterView
{
    self.navigationItem.title = @"注册";
    
    //动态图片
    UIImageView *registerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(250, 0, 100, 100)];
    [self.view addSubview:registerImageView];
    [registerImageView release];
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 1; i < 6; i++) {
        NSString *name = [NSString stringWithFormat:@"d%d", i];
        UIImage *image = [UIImage imageNamed:name];
        [array addObject:image];
    }
    registerImageView.animationImages = array;
    registerImageView.animationDuration = 2;
    registerImageView.animationRepeatCount = NSIntegerMax;
    [registerImageView startAnimating];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 380, 275, 150)];
    imageView.layer.borderWidth = 1.5;
    imageView.layer.cornerRadius = 5;
    [self.view addSubview:imageView];
    [imageView release];
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 1; i < 14; i++) {
        NSString *name = [NSString stringWithFormat:@"f%d", i];
        UIImage *image = [UIImage imageNamed:name];
        [arr addObject:image];
    }
    imageView.animationImages = arr;
    imageView.animationDuration = 2;
    imageView.animationRepeatCount = NSIntegerMax;
    [imageView startAnimating];
    
    //用户
    UILabel *userLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 100, 80, 40)];
    userLabel.text = @"用户名";
    userLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:userLabel];
    [userLabel release];
    UITextField *userTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 100, 180, 40)];
    userTextField.layer.borderWidth = 0.5;
    userTextField.layer.cornerRadius = 5;
    userTextField.placeholder = @"请输入用户名";
    userTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:userTextField];
    
    //密码
    UILabel *passWordLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 150, 80, 40)];
    passWordLabel.text = @"密码";
    passWordLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:passWordLabel];
    [passWordLabel release];
    UITextField *passWordTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 150, 180, 40)];
    passWordTextField.layer.borderWidth = 0.5;
    passWordTextField.layer.cornerRadius = 5;
    passWordTextField.placeholder = @"请输入密码";
    passWordTextField.secureTextEntry = YES;
    passWordTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:passWordTextField];
    
    //重复密码
    UILabel *repeatLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 200, 80, 40)];
    repeatLabel.text = @"重复密码";
    repeatLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:repeatLabel];
    [repeatLabel release];
    UITextField *repeatTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 200, 180, 40)];
    repeatTextField.layer.borderWidth = 0.5;
    repeatTextField.layer.cornerRadius = 5;
    repeatTextField.placeholder = @"请再次输入密码";
    repeatTextField.secureTextEntry = YES;
    repeatTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:repeatTextField];

    //联系方式
    UILabel *phoneNumLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 250, 80, 40)];
    phoneNumLabel.text = @"联系方式";
    phoneNumLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:phoneNumLabel];
    [phoneNumLabel release];
    UITextField *phoneNumTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 250, 180, 40)];
    phoneNumTextField.layer.borderWidth = 0.5;
    phoneNumTextField.layer.cornerRadius = 5;
    phoneNumTextField.placeholder = @"请输入联系方式";
    phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;
    phoneNumTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:phoneNumTextField];

    //联系方式
    UILabel *postLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 300, 80, 40)];
    postLabel.text = @"邮箱";
    postLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:postLabel];
    [postLabel release];
    UITextField *postTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 300, 180, 40)];
    postTextField.layer.borderWidth = 0.5;
    postTextField.layer.cornerRadius = 5;
    postTextField.placeholder = @"请输入邮箱";
    postTextField.keyboardType = UIKeyboardTypeEmailAddress;
    postTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:postTextField];
    
    //注册button
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeSystem];
    registerButton.frame = CGRectMake(50, 30, 100, 40);
    registerButton.layer.borderWidth = 0.5;
    registerButton.layer.cornerRadius = 5;
    registerButton.backgroundColor = [UIColor whiteColor];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerButton];
}

#pragma mark 注册点击方法
- (void)registerAction
{
    NSLog(@"注册");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您将要成为我们的伙伴" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
